package com.jiezheng.huinong.action;

import java.util.ArrayList;
import java.util.List;

import com.jiezheng.huinong.dao.PaperManageDAOImpl;
import com.jiezheng.huinong.model.PaperInfo;
import com.jiezheng.huinong.util.JqPage;
import com.opensymphony.xwork2.ActionSupport;

public class PaperInfoAction extends ActionSupport {

	/**
	 * serialVersionUID
	 */
	private static final long serialVersionUID = -5166804753938735537L;
	private JqPage pageInfo = new JqPage();
	private List<PaperInfo> papers = new ArrayList<PaperInfo>();
	private List<String> indexNos = new ArrayList<String>();
	private String sord = "";
	private String sidx = "";

	// 查询条件
	private String cond = "";

	/**
	 * 列出所有文号信息
	 * 
	 * @return
	 */
	public String listPaperInfo() {

		Integer total = (new PaperManageDAOImpl()).getTotalPaperNum(cond);
		Integer totalPage = (Integer) (total / pageInfo.getRows())
				+ ((total % pageInfo.getRows() == 0) ? 0 : 1);
		pageInfo.setTotalPage(totalPage);
		pageInfo.setRecord(total);
		// 取得当前页
		Integer curPage = pageInfo.getPage();
		Integer startRow = (curPage - 1) * pageInfo.getRows();

		papers = (new PaperManageDAOImpl()).getPaperInfo(cond, startRow,
				pageInfo.getRows());
		return "success";
	}

	/**
	 * 列出所有指标文号
	 * 
	 * @return
	 */
	public String listIndexNo() {
		indexNos = (new PaperManageDAOImpl()).listIndexNo();
		return SUCCESS;
	}

	public JqPage getPageInfo() {
		return pageInfo;
	}

	public void setPageInfo(JqPage pageInfo) {
		this.pageInfo = pageInfo;
	}

	public List<PaperInfo> getPapers() {
		return papers;
	}

	public void setPapers(List<PaperInfo> papers) {
		this.papers = papers;
	}

	public List<String> getIndexNos() {
		return indexNos;
	}

	public void setIndexNos(List<String> indexNos) {
		this.indexNos = indexNos;
	}

	public String getSord() {
		return sord;
	}

	public void setSord(String sord) {
		this.sord = sord;
	}

	public String getSidx() {
		return sidx;
	}

	public void setSidx(String sidx) {
		this.sidx = sidx;
	}

	public String getCond() {
		return cond;
	}

	public void setCond(String cond) {
		this.cond = cond;
	}

}
